$(document).ready(function() {
	   keter.navBar = new Vue({
		el : '.page-bar',
		data : {
			total : 1,    //分页总数
			cur : 1,      //当前页
			pageSize : 20,//每页记录数
			table:"",     //分页后赋值的对象
			baseUrl : ""  //分页请求基准URL
 		},
		computed : {
			indexs : function() {
				var left = 1
				var right = this.total
				var ar = []
				if (this.total >= 11) {
					if (this.cur > 5 && this.cur < this.total - 4) {
						left = this.cur - 5
						right = this.cur + 4
					} else {
						if (this.cur <= 5) {
							left = 1
							right = 10
						} else {
							right = this.total
							left = this.total - 9
						}
					}
				}
				while (left <= right) {
					ar.push(left)
					left++
				}
				return ar
			},
			showLast : function() {
				if (this.cur == this.total) {
					return false
				}
				return true
			},
			showFirst : function() {
				if (this.cur == 1) {
					return false
				}
				return true
			}
		},
		methods : {
			init : function(total,obj,baseUrl) {
				this.total=total;
				this.obj=obj;
				this.baseUrl=baseUrl;
			},
			btnClick : function(data) {
				//console.log("click:"+this.table.objs[0].id);
				if (data != this.cur) {
					this.cur = data
				}
				var _obj=this.obj;//使用临时对象传递作用域
				$.get(this.pagedUrl(this.baseUrl),function(data, status){
					//keter.navBar.table.objs = data.list;//JFinal返回的json分页对象中，数据保存在"list"属性内。
					_obj.items = data.list;
					//console.log(_table.items);
				});
			},
			pagedUrl : function(url) {
				return url+"/"+this.cur+'/'+keter.navBar.pageSize;
			},
		},
		watch : {
			cur : function(newValue, oldValue) {
				//console.log("调了我:" + newValue);
				this.btnClick(newValue);
			}
		}
	})
});